﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.IO;

namespace MulticastTV
{
    class ExportToM3UUdpRelay
    {
        public void Start(string file)
        {
            StreamWriter sw = File.CreateText(file);
            sw.WriteLine("#EXTM3U");
            DataView dw = ChannelTable.menu.Tables["Menu"].DefaultView;
            dw.Sort = "Chan";
            foreach (DataRowView dr in dw)
            {
                string ip = dr[0].ToString();
                int ch = (int)dr[1];

                sw.WriteLine("#EXTINF:0,Channel " + ch);
                sw.WriteLine("udp://@" + ip);
            }
            sw.Close();
        }
    }
}
